import java.util.Arrays;
import java.util.Scanner;

public class Test {

    //进制的转换

    //十进制转换为八进制
    public static void main1(String[] args) {
        int[] arr = new int[10];
        change(arr,8,2025);
        System.out.println(Arrays.toString(arr));
    }

    private static void change(int[] arr, int n, int x) {
        int len = 0;
        while(x > 0){
            arr[len++] = x % n;
            x /= n;
        }
    }


    //八进制转换为十进制
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int[] arr = new int[10];
        int len = 0;
        while(num > 0){
            arr[len++] = num % 10;
            num /= 10;
        }
        int ans = change2(arr,8,len);
        System.out.println(ans);

    }

    private static int change2(int[] arr, int n, int len) {
        int ans = 0;
        int w = 1;
        for (int i = 0; i < len; i++) {
            ans += arr[i] * w;
            w *= n;
        }
        return ans;
    }


}
